<?php  include VIEWPATH.'common/head.php';  ?>
    <script type="text/javascript">
        var status = '<?php echo $_GET['status'];?>';
        if(status == '-1'){
            alert('fail:<?php echo $_GET['msg'];?>');
        }

        function check_id(id){
            if(id == 0){
                var ids = document.getElementsByName('id[]');
                var sel_ids = '';
                for (var i = 0; i < ids.length; i++){
                    if (ids[i].checked) {
                        sel_ids += ids[i].value + ',';
                    }
                }
                if(sel_ids == ''){
                    alert('请选择要删除的用户');
                    return;
                }
                sel_ids = sel_ids.substr(0,sel_ids.length - 1);
                if(sel_ids == ''){
                    alert('请选择要删除的项');
                    return ;
                }
                id = sel_ids;
            }
            return id;
        }

        function setReDel(id){
            var id = check_id(id);
            if(confirm("确定删除吗？")){
                var url = 'index.php?c=report&m=report_del&id='+id;
                var param = {};
                common_ajax(url, param, function(data){
                    if(data.errorCode == 0) {
                        //表单提交
                        window.location.href= 'index.php?c=report&m=get_list&status=<?php echo $status_s?>&page=<?php echo $page;?>';
                        return;
                    }else{
                        alert(data.errorMsg);
                    }
                });
            }
        }
        function setReStatus(id, status){
            // var id = check_id(id);//只对单个数据处理
            var type=$('#type_'+id+'').val();
            var tag=$('#tag_'+id+'').val();
            var time=$('#time_'+id+'').val();
            var types=$('#types_'+id+'').val();
            if(status == 1 && tag ==''){
                alert('请选择属实的原因！');
                return false;
            }
            if(types == 0 && (type == '' || time == '') && status ==1){
                alert('处理用户请选择惩罚！');
                return false;
            }
            if(status == 1){
                var strings='属实';
            }else{
                var strings='不属实';
            }
            var url = 'index.php?c=report&m=report_status&id='+id+'&status='+status+'&type='+type+'&time='+time+'&tag='+tag;
            var param = {};
            if(confirm("确定要选为"+strings+"吗？确定后将为用户发送通知！")) {
                common_ajax(url, param, function (data) {
                    if (data.errorCode == 0) {
                        //表单提交
                        window.location.href = 'index.php?c=report&m=get_list&status=<?php echo $status_s?>&page=<?php echo $page;?>';
                        return;
                    } else {
                        alert(data.errorMsg);
                    }
                });
            }
        }
    </script>

    <body class="gray-bg">
    <div class="wrapper wrapper-content ">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>举报审核列表</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <div>
                                <!-- Nav tabs -->
                                <ul class="nav nav-tabs" role="tablist">

                                    <li <?php echo $status_s == 1 ?"class='active'":""?>>
                                        <a href="index.php?c=report&m=get_list&status=1">待审核</a>
                                    </li>

                                    <li <?php echo $status_s == '2' ?"class='active'":""?>>
                                        <a href="index.php?c=report&m=get_list&status=2">已审核</a>
                                    </li>

                                </ul>
                            </div>

                            <form class="form-horizontal" id="f_form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
<!--                                        <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>-->
                                        <th>举报人</th>
                                        <th>举报标签</th>
                                        <th>举报类型</th>
                                        <th>被举报</th>
                                        <th>状态</th>
                                        <?php
                                            if($status_s ==1){
                                                echo "<th>选择</th>";
                                            }
                                        ?>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php
                                    $reportType = $this->ReportModel->type;
                                    $reportTag = $this->ReportModel->tag;
                                    if(!empty($reportList)){
                                    foreach($reportList as $report) {
                                        $title = '';
                                        if($report['type'] == 0){ //用户
                                            $title = '<a class="J_menuItem" data-names="用户详情"  href="index.php?c=user&m=user_info&&uid='.$report['be_id'].'" target="_blank">'.$report['title'].'</a>';
                                        }else if($report['type'] == 1){ //帖子
                                            $title = '<a class="J_menuItem" data-names="帖子列表"  href="index.php?c=post&m=post_list&&s_type_id=1&s_content='.$report['be_id'].'" target="_blank">';
                                            $title.= $report['title']."</a>";
                                        }else if($report['type'] == 2){ //评论
                                            $title = '<a class="J_menuItem" data-names="评论管理"  href="index.php?c=comment&m=index&&s_type_id=5&s_content='.$report['be_id'].'" target="_blank">'.str_cut($report['title'],0,25)."</a>";
                                        }
                                        $user = $this->UserModel->query_one(array("uid" => $report['uid']));
                                        ?>
                                        <tr>
<!--                                            <th scope="row">-->
<!--                                                <input type="checkbox" name="id[]" value="--><?php //echo $report['id']; ?><!--" class="checkbox ck" />-->
<!--                                            </th>-->
                                            <td><?php echo $report['count']?></td>
                                            <td><?php echo $report['tag'];?></td>
                                            <td><?php echo $reportType[$report['type']]; ?></td>
                                            <td>
                                                <?php echo $title; ?>
                                            </td>
<!--                                            <td>--><?php //echo $report['content'];?><!--</td>-->
                                            <td nowrap="nowrap"><?php echo $report['status'] == 0 ? '待审核' : ($report['status'] == -1 ? '举报不属实' : '举报属实');?></td>
                                            <?php
                                            if($status_s ==1){
                                            ?>
                                            <td nowrap="nowrap">
                                                <div style="width: 200px;">
                                                    <select  name="tag_<?php echo $report['id']?>" id="tag_<?php echo $report['id']?>" class="form-control">
                                                        <option value="">请选择原因</option>
                                                        <?php
                                                         foreach ($reportTag as $k=>$v){
                                                             $str='<option value="'.$k.'">'.$v;
                                                             if(in_array($k,$report['tag_arr'])){
                                                                 $str.="(".$report['tag_num'][$k].")";
                                                             }else{
                                                                 $str.="(0)";

                                                             }
                                                             $str.='</option>';
                                                             echo $str;
                                                         }
                                                        ?>
                                                    </select>
                                                    <?php
                                                    if($report['type'] == 0){
                                                    ?>
                                                    <br>

                                                    <select name="type_<?php echo $report['id']?>" id="type_<?php echo $report['id']?>" class="form-control">
                                                        <option value="">请选择惩罚类型</option>
                                                        <option value="4">禁言</option>
                                                        <option value="5">禁闭</option>
                                                        <option value="6">封号</option>
                                                    </select>
                                                    <br>
                                                    <select name="time_<?php echo $report['id']?>" id="time_<?php echo $report['id']?>" class="form-control">
                                                        <option value="">请选择惩罚时间</option>
                                                        <option value="1">30分钟</option>
                                                        <option value="2">一小时</option>
                                                        <option value="3">24小时</option>
                                                        <option value="7">3天</option>
                                                        <option value="4">7天</option>
                                                        <option value="5">永久</option>
                                                        <option value="6">解除</option>
                                                    </select>
                                                <?php }?>
                                                </div>
                                                <input type="hidden" id="types_<?php echo $report['id']?>" value="<?php echo $report['type']; ?>">
                                            </td>
                                            <?php }?>


                                            <td nowrap="nowrap">
                                                <?php if($report['status'] == 0){ ?>
                                                    <a href="javascript:void(0)" onclick="setReStatus(<?php echo $report['id']; ?>, 1)" class="btn btn-white btn-sm">属实</a>
                                                    <a href="javascript:void(0)" onclick="setReStatus(<?php echo $report['id']; ?>, -1)" class="btn btn-white btn-sm">不属实</a>
                                                <?php }?>
                                            </td>
                                        </tr>
                                    <?php }}?>
                                    </tbody>
                                </table>
                                <div class="set_page">
                                    <?php echo $multipage; ?>
                                    <div class="clearfix"></div>
                                </div>
                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>


<?php  include VIEWPATH.'common/footer.php';  ?>